package assignment11;

import java.io.*;

public class ObjSerializable {
	public static void main(String args[]) throws IOException, ClassNotFoundException {
	    Book book=new Book(100032,"Java Programming Skills","Wang Sir",30);
	    String pathname = "G:\\Users\\IOtest\\book.dat";
	    //对象序列化
	    ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(pathname));
        oos.writeObject(book);
	    oos.close();
	    book=null;
	    //对象反序列化
	    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(pathname));
	    book=(Book)ois.readObject();
	    ois.close();
 	    System.out.println("ID is:"+book.id);
	    System.out.println("name is:"+book.name);
	    System.out.println("author is:"+book.author);
	    System.out.println("price is:"+book.price);
	}
}